<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>后台登录</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no"/>
    <link rel="stylesheet" href="/static/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/static/css/login.css" media="all">
</head>
<body>
<div class="layui-container login-container">
    <div class="login-main">
        <div class="login-header">
            <h2>后台管理登录</h2>
        </div>
        <form class="layui-form">
            <div class="layui-form-item">
                <label class="layui-form-label layui-icon layui-icon-username login-icon" for="username"></label>
                <input type="text" name="username" id="username" required lay-verify="required" placeholder="用户名" autocomplete="off" class="layui-input">
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label layui-icon layui-icon-password login-icon" for="password"></label>
                <input type="password" name="password" id="password" required lay-verify="required" placeholder="密码" autocomplete="off" class="layui-input">
            </div>
            <div class="layui-form-item">
                <button type="submit" class="layui-btn layui-btn-fluid">登  录</button>
            </div>
            <div class="layui-form-item">
                <p class="copyright">&copy; 2019-{{ date('Y') }} <a href="https://www.yangdx.com/" target="_blank">YANGDX.COM</a> 版权所有</p>
            </div>
        </form>
    </div>
</div>
<script src="/static/layui/layui.js"></script>
{{--<script src="https://ssl.captcha.qq.com/TCaptcha.js"></script>--}}
<script>
    if (window.self != window.top) {
        window.top.location = window.self.location;
    }

    layui.use(['layer', 'form'], function () {
        var $ = layui.$;
        var layer = layui.layer;
        var form = layui.form;
        var loading = 0;

        form.on('submit', function () {
            if (loading == 1) {
                return false;
            }

            {{--new TencentCaptcha("{{config('blog.tencent_captcha_id')}}", function (res) {--}}
            {{--    if (res.ret !== 0) {--}}
            {{--        return;--}}
            {{--    }--}}

                loading = 1;

                var data = {
                    username: $("#username").val(),
                    password: $("#password").val(),
                    {{-- captcha_ticket: res.ticket,--}}
                    {{-- captcha_randstr: res.randstr,--}}
                };

                $.post('/admin/login', data, function (res) {
                    loading = 0;
                    if (res.code === 0) {
                        location.href = '/admin/index';
                    } else {
                        layer.msg(res.msg, {icon: 5});
                    }
                }, 'json');
            {{-- }).show();--}}

            return false;
        });

    });
</script>
</body>
</html>
